$(function () {

    //变量抽取
    var transferRecord_dataGrid = $("#transferRecord_dataGrid");

    //页面数据列表
    transferRecord_dataGrid.datagrid({
        url: "/transferRecord/query.do",
        fitColumns: true,//列自适应
        fit: true,
        align: 'center',
        columns: [[
            {field: 'removeDate', title: '移交日期', width: 100,align:'center'},
            {field: 'removeEmp', title: '操作人员', width: 100,align:'center'},
            {field: 'clientName', title: '客户', width: 100,align:'center'},
            {field: 'oldChargeEmp', title: '原市场专员', width: 100,align:'center'},
            {field: 'newChargeEmp', title: '新市场专员', width: 100,align:'center'},
            {field: 'remark', title: '移交原因', width: 100,align:'center'},
        ]],
        toolbar: "#tb",//工具
        pagination: true,//分页
        rownumbers: true,//行号
        singleSelect: true//只允许选择一行
    });

    //方法抽成对象统一管理
    var methodObj = {//添加按钮

        //刷新按钮
        reload: function () {
            //清空查询条件
            $("#beginDate").textbox("setValue",'');
            $("#endDate").textbox("setValue",'');
            $("#removeEmp").textbox("setValue",'');
            $("#clientName").textbox("setValue",'');
            $("#oldChargeEmp").textbox("setValue",'');
            $("#newChargeEmp").textbox("setValue",'');
            transferRecord_dataGrid.datagrid("load",{});
        },

        //查询按钮
        searchForm:function () {
            //获取输入框的内容
            var beginDate = $("[name=beginDate]").val();
            var endDate = $("[name=endDate]").val();
            var removeEmp = $("[name=removeEmp]").val();
            var clientName = $("[name=clientName]").val();
            var oldChargeEmp = $("[name=oldChargeEmp]").val();
            var newChargeEmp = $("[name=newChargeEmp]").val();

            transferRecord_dataGrid.datagrid('load', {
                beginDate: beginDate,
                endDate: endDate,
                removeEmp: removeEmp,
                clientName: clientName,
                oldChargeEmp: oldChargeEmp,
                newChargeEmp: newChargeEmp
            });
        }
    };

    //按钮统一绑定事件
    $("a[data-cmd]").click(function () {
        var cmd = $(this).data("cmd");
        methodObj[cmd]();
    });

});


